<?php 
class GmailCommand extends CConsoleCommand {
    public function run($args) {
		$credentials = Yii::app()->db->createCommand()
		->select('glogin, gpassword')
		->from('tbl_users')
		->where('username=:username', array(':username'=>'sales'))
		->queryRow();
		$messages = Yii::app()->gmail->getMessages($credentials["glogin"], $credentials["gpassword"]);
		$this->render('view', array('msg' => $messages));
    }
	
	public function render($template, array $data = array()){
		$path = Yii::getPathOfAlias('ext.gmail.views').'/'.$template.'.php';
		if(!file_exists($path)) throw new Exception('Template '.$path.' does not exist.');
		return $this->renderFile($path, $data, true);
	}
}
?>